from machine import ADC, Pin


class Trimpot(object):
    """基本描述
    EF05018电位器
    """

    def __init__(self, pin):
        self.__pin = pin
        adc = ADC(Pin(self.__pin))
        adc.atten(ADC.ATTN_11DB)
        adc.width(ADC.WIDTH_12BIT)  # 4095
        self.__adc = adc

    def get_analog(self):
        return self.__adc.read()


if __name__ == "__main__":
    import time

    tri = Trimpot(0)
    while True:
        print(tri.get_analog())
        time.sleep(2)
